<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>If var [not] between LowerBound and UpperBound</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../css/default.css" rel="stylesheet" type="text/css">
</head>
<body>

<h1>If var [not] between LowerBound and UpperBound</h1>

<p>根据数值或字母顺序检查 <a href="../Variables.htm">变量的</a> 内容是否在两个值之间 (包含边界).</p>

<pre class="Syntax">if <i>Var</i> between <i>LowerBound</i> and <i>UpperBound</i>
if <i>Var</i> not between <i>LowerBound</i> and <i>UpperBound</i></pre>
<h3>参数</h3>
<table class="info">
  <tr> 
    <td width="15%">Var</td>
    <td width="85%">需要被检查的 <a href="../Variables.htm">变量</a> 名称.</td>
  </tr>
  <tr>
    <td>LowerBound</td>
    <td>指定范围的下限, <em>Var</em> 必须大于或等于此字符串, 数字或变量引用.</td>
  </tr>
  <tr>
    <td>UpperBound</td>
    <td>指定范围的上限, <em>Var</em> 必须小于或等于此字符串, 数字或变量引用.</td>
  </tr>
</table>

<h3>备注</h3>
<p>如果这三个参数都为纯数值, 那么它们将被作为数字而不是字符串进行比较. 其他情况下, 它们将被作为字符串按字母顺序进行比较 (即字母次序将决定 <em>Var</em> 是否在指定范围内). 此时, 可以使用 <em>"</em><a href="StringCaseSense.htm"><em>StringCaseSense</em></a><em> On</em>" 来设置在比较时区分大小写.</p>
<p><strong>运算符 "between", "is", "in" 和 "contains" 不支持用于 <a href="../Variables.htm#Expressions">表达式</a> 中.</strong></p>
<h3>相关</h3>
<p><a href="IfEqual.htm">IfEqual/Greater/Less</a>, <a href="IfIn.htm">if var in/contains MatchList</a>, <a href="IfIs.htm">if var is type</a>, <a href="IfInString.htm">IfInString</a>, <a href="StringCaseSense.htm">StringCaseSense</a>, <a href="EnvAdd.htm">EnvAdd</a><a href="Block.htm">, 区块</a>, <a href="Else.htm">Else</a></p>
<h3>示例</h3>
<pre class="NoIndent">if var between 1 and 5
    MsgBox, %var% is in the range 1 to 5, inclusive.

if var <strong>not </strong>between 0.0 and 1.0
    MsgBox %var% is not in the range 0.0 to 1.0, inclusive.

if var between %VarLow% and %VarHigh%
    MsgBox %var% is between %VarLow% and %VarHigh%.

if var between blue and red
    MsgBox %var% is alphabetically between the words blue and red.

LowerLimit = 1
UpperLimit = 10
InputBox, UserInput, Enter a number between %LowerLimit% and %UpperLimit%
if UserInput not between %LowerLimit% and %UpperLimit%
    MsgBox Your input is not within the valid range.</pre>

</body>
</html>
